﻿Imports VendasDAL
Public Class ClientesRelFRM
    Private Sub rbativo_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rbativo.CheckedChanged
        If rbativo.Checked Then gerarelatrio("Relatórios de Clientes Ativos", "{Ofi_Cliente.sta_codigo}=1")
    End Sub

    Private Sub rbinativo_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rbinativo.CheckedChanged
        If rbinativo.Checked Then gerarelatrio("Relatórios de Clientes Inativos", "{Ofi_Cliente.sta_codigo}=2")
    End Sub

    Private Sub rbtodos_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rbtodos.CheckedChanged
        If rbtodos.Checked Then gerarelatrio("Todos Clientes", "")
    End Sub

#Region "Relatorio"
    Public Sub gerarelatrio(titulo As String, formula As String)
        Try
            Dim frmrecursos As New RelatoriosVendaFRM
            Dim rpt As New CRTodosCLientes
            Try
                rpt.SetDatabaseLogon(usuario, senha)
                rpt.SetParameterValue(0, titulo)
                rpt.RecordSelectionFormula = formula
                frmrecursos.CRVRelatorio.ShowGroupTreeButton = False
                frmrecursos.CRVRelatorio.ReportSource = rpt
                frmrecursos.ShowDialog()
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
            frmrecursos.Dispose()
            rpt = Nothing
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Finally

        End Try
    End Sub
#End Region

    Private Sub ClientesRelFRM_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class